<template>
    <base-dialog  v-bind="$attrs" v-on="$listeners" title="请选择菜单" size="tiny" @submit="toSubmit" top="200px">
        <el-form  ref="elForm" size="medium" label-width="80px">
        <el-form-item label="目标菜单">
            <dept-select-tree v-model="target"  placeholder="选择目标菜单"
                              :disable-branch-nodes="true" dept-type="other" :all-dept-list="menuList"></dept-select-tree>
        </el-form-item>
        </el-form>
    </base-dialog>
</template>
<script>
    import BaseDialog from "@/components/Common/BaseDialog";
    import DeptSelectTree from "@/components/Common/DeptSelectTree";
    import menu from "@/api/menuManagement/index";
    export default {
        components: {DeptSelectTree, BaseDialog},
        props:["menuList","row"],
        name:"CopyHandleDialog",
        data(){
            return{
                target:undefined
            }
        },
        methods:{
            toSubmit(){
                if(this.target){
                    menu.setAccountsMenuCopy(this.row.id,{"target":this.target}).then(res=>{
                        this.$emit("reloadList")
                        this.msgSuccess(res.msg)
                        this.$emit("update:visible",false)
                    })
                }else{
                    this.msgError("请选择目标菜单")
                }
            },
            /** 转换菜单数据结构 */
            normalizer(node) {
                if (node.children && !node.children.length) {
                    delete node.children;
                }
                return {
                    id: node.id,
                    label: node.name,
                    children: node.children
                };
            },
        }
    }
</script>
<style lang="scss" scoped>

</style>
